import { PropType, ExtractPropTypes } from 'vue';
import { createPropsResolver } from '../../dynamic-resolver';
import autoCompleteSchema from './schema/auto-complete.schema.json';
import { schemaMapper } from './schema/schema-mapper';

export const autoCompleteProps = {
    /**
     * 组件标识
     */
    id: String,
    /**
     * 组件自定义样式
     */
    customClass: { type: String, default: '' },
    /**
     * 数组数据源
     */
    dataSource: Array as PropType<{ value: any; text: any }[] | string[]>,
    /**
     * 下拉框和选择器同宽
     */
    dropdownMatchSelectWidth: { type: [Number, Boolean], default: true },
    /**
     * 是否根据输入项进行筛选 默认true
     */
    filterOption: { type: [Boolean, Function], default: false },
} as Record<string, any>;

export type AutoCompleteProps = ExtractPropTypes<typeof autoCompleteProps>;

export const propsResolver = createPropsResolver<AutoCompleteProps>(autoCompleteProps, autoCompleteSchema, schemaMapper);
